/*
 * INSANE - Interactive Structural Analysis Environment
 *
 * Copyright (C) 2003-2005
 * Universidade Federal de Minas Gerais
 * Escola de Engenharia
 * Departamento de Engenharia de Estruturas
 * 
 * Author's email :    insane@dees.ufmg.br
 * Author's website :  http://www.dees.ufmg.br/insane
 * 
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License
 * as published by the Free Software Foundation; either version 2
 * of the License, or any later version.
 * 
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 * 
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
 */
package br.ufmg.dees.insane.ui.rich.postp.postp_view.dialog;

import java.awt.Dimension;
import java.awt.Font;
import java.awt.Frame;
import java.awt.Insets;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import javax.swing.BorderFactory;
import javax.swing.JButton;
import javax.swing.JCheckBox;
import javax.swing.JColorChooser;
import javax.swing.JComboBox;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JRadioButton;
import javax.swing.JTextField;
import javax.swing.WindowConstants;
import javax.swing.border.TitledBorder;

import br.ufmg.dees.insane.commons.view.ViewState;
import br.ufmg.dees.insane.ui.rich.postp.postp_view.DesktopPostp;
import br.ufmg.dees.insane.ui.rich.postp.postp_view.FaceViewState;
import br.ufmg.dees.insane.ui.rich.postp.postp_view.InterfacePostp;
import br.ufmg.dees.insane.ui.rich.postp.postp_view.PostpViewState;

/**
 *
 * @author  Samuel Silva Penna
 */
public class FaceSettingsDialog extends javax.swing.JDialog {
	
	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;
//	Variables declaration - do not modify                     
	private JButton faceColorChooseButton;
	private JButton faceStateColorChooseButton;
	private JButton viewButton;
	private JButton cancelButton;
	private JButton okButton;
	private JButton labelColorChooseButton;
	private JCheckBox labelOnCheckBox;
	private JCheckBox labelOffCheckBox;
	private JCheckBox modifyAllCheckBox;
	private JCheckBox modifySelectedCheckBox;
	private JComboBox fontComboBox;
	private JComboBox fontSizeComboBox;
	private JComboBox fillTypeFaceComboBox;
	private JComboBox fillTypeStateFaceComboBox;
	private JLabel jLabel1;
	private JLabel jLabel2;
	private JLabel jLabel3;
	private JLabel jLabel4;
	private JLabel jLabel5;
	private JLabel jLabel6;
	private JLabel jLabel7;
	private JLabel jLabel8;
	private JLabel jLabel9;
	private JPanel labelPanel;
	private JPanel faceSettingsPanel;
	private JPanel stateFacePanel;
	private JRadioButton plainRadioButton;
	private JRadioButton italicRadioButton;
	private JRadioButton boldRadioButton;
	private JTextField intensityFillFaceTextField;
	private JTextField faceColorTextField;
	private JTextField intensityFillStateFaceTextField;
	private JTextField faceStateColorTextField;
	private JTextField labelColorTextField;
	// End of variables declaration    
	
	private DesktopPostp desktop;
	private PostpViewState state;
	
	/** Creates new form FaceSettingsDialog */
	public FaceSettingsDialog(Frame parent, boolean modal) {
		super(parent, modal);
		initComponents();
	}
	
	/** Creates new form FaceSettingsDialog */
	public FaceSettingsDialog(ViewState vs,Frame parent, boolean modal) {
		super(parent, modal);
		this.state = (PostpViewState)vs;
		initComponents();
	}
	
	/** This method is called from within the constructor to
	 * initialize the form.
	 * WARNING: Do NOT modify this code. The content of this method is
	 * always regenerated by the Form Editor.
	 */
	// <editor-fold defaultstate="collapsed" desc=" Generated Code ">                          
	private void initComponents() {
		this.setSize(new Dimension(350,445));
		this.setPreferredSize(new Dimension(350,445));
		this.setMaximumSize(new Dimension(350,445));
		this.setMinimumSize(new Dimension(350,445));
		
		this.setResizable(false);
		this.setTitle("Faces Settings Dialogs");
		this.setLocationRelativeTo(this.desktop);
		//Image ico = Toolkit.getDefaultToolkit().getImage(ClassLoader.getSystemResource("br/ufmg/dees/insane/images/Insane64.gif"));
		//this.setIconImage(ico);
		setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
		
		labelPanel = new JPanel();
		jLabel1 = new JLabel();
		jLabel2 = new JLabel();
		fontComboBox = new JComboBox();
		fontSizeComboBox = new JComboBox();
		plainRadioButton = new JRadioButton();
		italicRadioButton = new JRadioButton();
		boldRadioButton = new JRadioButton();
		labelOnCheckBox = new JCheckBox();
		labelOffCheckBox = new JCheckBox();
		labelColorTextField = new JTextField();
		labelColorChooseButton = new JButton();
		jLabel9 = new JLabel();
		faceSettingsPanel = new JPanel();
		jLabel3 = new JLabel();
		fillTypeFaceComboBox = new JComboBox();
		jLabel4 = new JLabel();
		jLabel5 = new JLabel();
		intensityFillFaceTextField = new JTextField();
		faceColorChooseButton = new JButton();
		faceColorTextField = new JTextField();
		stateFacePanel = new JPanel();
		jLabel6 = new JLabel();
		fillTypeStateFaceComboBox = new JComboBox();
		jLabel7 = new JLabel();
		jLabel8 = new JLabel();
		intensityFillStateFaceTextField = new JTextField();
		faceStateColorChooseButton = new JButton();
		faceStateColorTextField = new JTextField();
		viewButton = new JButton();
		cancelButton = new JButton();
		okButton = new JButton();
		modifyAllCheckBox = new JCheckBox();
		modifySelectedCheckBox = new JCheckBox();
		
		getContentPane().setLayout(null);
		
		//Label Panel
		labelPanel.setLayout(null);
		labelPanel.setBorder(BorderFactory.createTitledBorder(null, "Label Settings", TitledBorder.DEFAULT_JUSTIFICATION,
				TitledBorder.DEFAULT_POSITION, new Font("Arial", 0, 11)));
		
		jLabel1.setText("Font");
		jLabel1.setFont(new Font("Arial", Font.PLAIN, 11));
		labelPanel.add(jLabel1);
		jLabel1.setBounds(10, 20, 22, 25);
		
		fontComboBox.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Arial", "Monospaced", "SansSerif", "Time" }));
		fontComboBox.setSelectedItem(this.state.getFaceViewState().getTextFont());
		fontComboBox.setFont(new Font("Arial", Font.PLAIN, 11));
		labelPanel.add(fontComboBox);
		fontComboBox.setBounds(50, 20, 140, 25);
		
		jLabel2.setText("Size");
		jLabel2.setFont(new Font("Arial", Font.PLAIN, 11));
		labelPanel.add(jLabel2);
		jLabel2.setBounds(210, 20, 80, 25);
		
		fontSizeComboBox.setModel(new javax.swing.DefaultComboBoxModel(new String[] {"2","4","6","8","10","12","16","18"}));
		fontSizeComboBox.setSelectedItem(this.state.getFaceViewState().getTextSize()+"");
		fontSizeComboBox.setFont(new Font("Arial", Font.PLAIN, 11));
		fontSizeComboBox.setEditable(true);
		labelPanel.add(fontSizeComboBox);
		fontSizeComboBox.setBounds(240, 20, 90, 25);
		
		plainRadioButton.setText("Plain");
		plainRadioButton.setFont(new Font("Arial", Font.PLAIN, 11));
		plainRadioButton.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 0));
		plainRadioButton.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				if(plainRadioButton.isSelected()){
					boldRadioButton.setSelected(false);
				}else{
					boldRadioButton.setSelected(true);
				}
			}
		} );
		plainRadioButton.setMargin(new Insets(0, 0, 0, 0));
		labelPanel.add(plainRadioButton);
		plainRadioButton.setBounds(10, 60, 50, 20);
		
		italicRadioButton.setText("Italic");
		italicRadioButton.setFont(new Font("Arial", Font.PLAIN, 11));
		italicRadioButton.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 0));
		italicRadioButton.setMargin(new Insets(0, 0, 0, 0));
		labelPanel.add(italicRadioButton);
		italicRadioButton.setBounds(65, 60, 50, 20);
		
		boldRadioButton.setText("Bold");
		boldRadioButton.setFont(new Font("Arial", Font.PLAIN, 11));
		boldRadioButton.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 0));
		boldRadioButton.setMargin(new Insets(0, 0, 0, 0));
		boldRadioButton.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				if(boldRadioButton.isSelected()){
					plainRadioButton.setSelected(false);
				}else{
					plainRadioButton.setSelected(true);
				}
			}
		} );
		labelPanel.add(boldRadioButton);
		boldRadioButton.setBounds(120, 60, 50, 20);
		
		if(this.state.getFaceViewState().getTextStyle()==0){
			plainRadioButton.setSelected(true);
			boldRadioButton.setSelected(false);
			italicRadioButton.setSelected(false);
		}
		if(this.state.getFaceViewState().getTextStyle()==1){
			plainRadioButton.setSelected(false);
			boldRadioButton.setSelected(true);
			italicRadioButton.setSelected(false);
		}
		if(this.state.getFaceViewState().getTextStyle()==2){
			plainRadioButton.setSelected(true);
			boldRadioButton.setSelected(false);
			italicRadioButton.setSelected(true);
		}
		if(this.state.getFaceViewState().getTextStyle()==3){
			plainRadioButton.setSelected(false);
			boldRadioButton.setSelected(true);
			italicRadioButton.setSelected(true);
		}
		
		labelOnCheckBox.setText("Label On");
		labelOnCheckBox.setFont(new Font("Arial", Font.PLAIN, 11));
		labelOnCheckBox.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 0));
		labelOnCheckBox.setMargin(new Insets(0, 0, 0, 0));
		labelOnCheckBox.setSelected(this.state.getFaceViewState().isLabelOn());
		labelOnCheckBox.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				if(labelOnCheckBox.isSelected()){
					labelOffCheckBox.setSelected(false);
				}else{
					labelOffCheckBox.setSelected(true);
				}
			}
		} );
		labelPanel.add(labelOnCheckBox);
		labelOnCheckBox.setBounds(195, 60, 60, 20);
		
		labelOffCheckBox.setText("Label Off");
		labelOffCheckBox.setFont(new Font("Arial", Font.PLAIN, 11));
		labelOffCheckBox.setBorder(javax.swing.BorderFactory.createEmptyBorder(0, 0, 0, 0));
		labelOffCheckBox.setMargin(new java.awt.Insets(0, 0, 0, 0));
		labelOffCheckBox.setSelected(!this.state.getFaceViewState().isLabelOn());
		labelOffCheckBox.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				if(labelOffCheckBox.isSelected()){
					labelOnCheckBox.setSelected(false);
				}else{
					labelOnCheckBox.setSelected(true);
				}
			}
		} );
		labelPanel.add(labelOffCheckBox);
		labelOffCheckBox.setBounds(265, 60, 65, 20);
		
		labelColorTextField.setText("");
		labelColorTextField.setEditable(false);
		labelColorTextField.setBackground(this.state.getFaceViewState().getLabelColor());
		labelPanel.add(labelColorTextField);
		labelColorTextField.setBounds(250, 90, 80, 25);
		
		labelColorChooseButton.setText("Choose");
		labelColorChooseButton.setFont(new Font("Arial", Font.PLAIN, 11));
		labelPanel.add(labelColorChooseButton);
		labelColorChooseButton.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				faceLabelsColorActionPerformed(e);
			}
		} );
		labelColorChooseButton.setBounds(170, 90, 73, 25);
		
		jLabel9.setText("Label Color");
		jLabel9.setFont(new Font("Arial", Font.PLAIN, 11));
		labelPanel.add(jLabel9);
		jLabel9.setBounds(100, 90, 80, 25);
		
		getContentPane().add(labelPanel);
		labelPanel.setBounds(0, 0, 340, 130);
		
		//Face settings Panel
		faceSettingsPanel.setLayout(null);
		faceSettingsPanel.setBorder(BorderFactory.createTitledBorder(null, "Face Settings", TitledBorder.DEFAULT_JUSTIFICATION,
				TitledBorder.DEFAULT_POSITION, new Font("Arial", 0, 11)));
		
		jLabel3.setText("Fill Type");
		jLabel3.setFont(new Font("Arial", 0, 11));
		faceSettingsPanel.add(jLabel3);
		jLabel3.setBounds(10, 20, 50, 25);
		
		fillTypeFaceComboBox.setModel(new javax.swing.DefaultComboBoxModel(new String[] {"NONE", "Transparent","Opaque" }));
		fillTypeFaceComboBox.setFont(new Font("Arial", 0, 11));
		fillTypeFaceComboBox.setSelectedItem(this.state.getFaceViewState().getFillType());
		faceSettingsPanel.add(fillTypeFaceComboBox);
		fillTypeFaceComboBox.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				if(fillTypeFaceComboBox.getSelectedItem()=="Transparent"){
					intensityFillFaceTextField.setEnabled(true);
				}else{
					intensityFillFaceTextField.setEnabled(false);
				}
			}
		} );
		fillTypeFaceComboBox.setBounds(60, 20, 110, 25);
		
		jLabel5.setText("Intensity");
		jLabel5.setFont(new Font("Arial", 0, 11));
		faceSettingsPanel.add(jLabel5);
		jLabel5.setBounds(195, 20, 50, 25);
		
		intensityFillFaceTextField.setText(this.state.getFaceViewState().getIntensity()+"");
		if(fillTypeFaceComboBox.getSelectedItem()=="Transparent"){
			intensityFillFaceTextField.setEnabled(true);
		}else{
			intensityFillFaceTextField.setEnabled(false);
		}
		intensityFillFaceTextField.setFont(new Font("Arial", 0, 11));
		faceSettingsPanel.add(intensityFillFaceTextField);
		intensityFillFaceTextField.setBounds(250, 20, 83, 25);
		
		jLabel4.setText("Face Color");
		jLabel4.setFont(new Font("Arial", 0, 11));
		faceSettingsPanel.add(jLabel4);
		jLabel4.setBounds(100, 60, 60, 25);
		
		faceColorTextField.setText("");
		faceColorTextField.setEditable(false);
		faceColorTextField.setBackground(this.state.getFaceViewState().getFillColor());
		faceColorChooseButton.setFont(new Font("Arial", 0, 11));
		faceSettingsPanel.add(faceColorTextField);
		faceColorTextField.setBounds(250, 60, 80, 25);
		
		faceColorChooseButton.setText("Choose");
		faceColorChooseButton.setFont(new Font("Arial", 0, 11));
		faceSettingsPanel.add(faceColorChooseButton);
		faceColorChooseButton.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				faceColorActionPerformed(e);
			}
		} );
		faceColorChooseButton.setBounds(170, 60, 73, 25);
		
		getContentPane().add(faceSettingsPanel);
		faceSettingsPanel.setBounds(0, 130, 340, 100);
		
		//State Settings Panel
		stateFacePanel.setLayout(null);
		stateFacePanel.setBorder(BorderFactory.createTitledBorder(null, "State Settings", TitledBorder.DEFAULT_JUSTIFICATION,
				TitledBorder.DEFAULT_POSITION, new Font("Arial", 0, 11)));
		
		jLabel6.setText("Fill Type");
		jLabel6.setFont(new Font("Arial", 0, 11));
		stateFacePanel.add(jLabel6);
		jLabel6.setBounds(10, 20, 50, 25);
		
		fillTypeStateFaceComboBox.setModel(new javax.swing.DefaultComboBoxModel(new String[] {"NONE", "Transparent","Opaque" }));
		fillTypeStateFaceComboBox.setSelectedItem(this.state.getFaceViewState().getFillStateType());
		fillTypeStateFaceComboBox.setFont(new Font("Arial", 0, 11));
		stateFacePanel.add(fillTypeStateFaceComboBox);
		fillTypeStateFaceComboBox.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				if(fillTypeStateFaceComboBox.getSelectedItem()=="Transparent"){
					intensityFillStateFaceTextField.setEnabled(true);
				}else{
					intensityFillStateFaceTextField.setEnabled(false);
				}
			}
		} );
		fillTypeStateFaceComboBox.setBounds(60, 20, 110, 25);
		
		jLabel8.setText("Intensity");
		jLabel8.setFont(new Font("Arial", 0, 11));
		stateFacePanel.add(jLabel8);
		jLabel8.setBounds(200, 20, 50, 25);
		
		jLabel7.setText("Face Color");
		jLabel7.setFont(new Font("Arial", 0, 11));
		stateFacePanel.add(jLabel7);
		jLabel7.setBounds(110, 60, 60, 25);
		
		intensityFillStateFaceTextField.setText(this.state.getFaceViewState().getIntensityState()+"");
		if(fillTypeStateFaceComboBox.getSelectedItem()=="Transparent"){
			intensityFillStateFaceTextField.setEnabled(true);
		}else{
			intensityFillStateFaceTextField.setEnabled(false);
		}
		intensityFillStateFaceTextField.setFont(new Font("Arial", 0, 11));
		stateFacePanel.add(intensityFillStateFaceTextField);
		intensityFillStateFaceTextField.setBounds(250, 20, 83, 25);
		
		faceStateColorChooseButton.setText("Choose");
		faceStateColorChooseButton.setFont(new Font("Arial", 0, 11));
		stateFacePanel.add(faceStateColorChooseButton);
		faceStateColorChooseButton.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				faceStateColorActionPerformed(e);
			}
		} );
		faceStateColorChooseButton.setBounds(170, 60, 73, 25);
		
		faceStateColorTextField.setText("");
		faceStateColorTextField.setEditable(false);
		faceStateColorTextField.setBackground(this.state.getFaceViewState().getFillStateColor());
		faceStateColorTextField.setFont(new Font("Arial", 0, 11));
		stateFacePanel.add(faceStateColorTextField);
		faceStateColorTextField.setBounds(250, 60, 80, 25);
		
		getContentPane().add(stateFacePanel);
		stateFacePanel.setBounds(0, 230, 340, 100);
		
		//Setting buttons
		viewButton.setText("View");
		viewButton.setFont(new Font("Arial", 0, 11));
		getContentPane().add(viewButton);
		viewButton.setBounds(10, 380, 70, 25);
		
		cancelButton.setText("Cancel");
		cancelButton.setFont(new Font("Arial", 0, 11));
		getContentPane().add(cancelButton);
		cancelButton.setBounds(260, 380, 70, 25);
		
		okButton.setText("OK");
		okButton.setFont(new Font("Arial", 0, 11));
		getContentPane().add(okButton);
		okButton.setBounds(185, 380, 70, 25);
		
		modifyAllCheckBox.setText("Modify all windows");
		modifyAllCheckBox.setFont(new Font("Arial", 0, 11));
		modifyAllCheckBox.setBorder(javax.swing.BorderFactory.createEmptyBorder(0, 0, 0, 0));
		modifyAllCheckBox.setMargin(new java.awt.Insets(0, 0, 0, 0));
		modifyAllCheckBox.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				if(modifyAllCheckBox.isSelected()){
					modifySelectedCheckBox.setSelected(false);
				}else{
					modifySelectedCheckBox.setSelected(true);
				}
			}
		} );
		getContentPane().add(modifyAllCheckBox);
		modifyAllCheckBox.setBounds(10, 340, 120, 25);
		
		modifySelectedCheckBox.setText("Modify selected window");
		modifySelectedCheckBox.setFont(new Font("Arial", 0, 11));
		modifySelectedCheckBox.setBorder(javax.swing.BorderFactory.createEmptyBorder(0, 0, 0, 0));
		modifySelectedCheckBox.setMargin(new java.awt.Insets(0, 0, 0, 0));
		modifySelectedCheckBox.setSelected(true);
		modifySelectedCheckBox.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				if(modifySelectedCheckBox.isSelected()){
					modifyAllCheckBox.setSelected(false);
				}else{
					modifyAllCheckBox.setSelected(true);
				}
			}
		} );
		getContentPane().add(modifySelectedCheckBox);
		modifySelectedCheckBox.setBounds(140, 340, 140, 25);
		
		viewButton.addActionListener(
				new ActionListener(){
					public void actionPerformed(ActionEvent event){
						approvedPerform();
					}
				});
		
		okButton.addActionListener(
				new ActionListener(){
					public void actionPerformed(ActionEvent event){
						approvedPerform();
						close();
					}
				});
		
		cancelButton.addActionListener(
				new ActionListener(){
					public void actionPerformed(ActionEvent event){
						close();
					}
				});
		
	}// </editor-fold>                        
	
	
	private void close(){
		this.dispose();
	}
	
	private void approvedPerform(){
		if(modifyAllCheckBox.isSelected()){
			for(int i=0;i<this.desktop.getDesktop().getAllFrames().length;i++){
				if(this.desktop.getDesktop().getAllFrames()[i] instanceof InterfacePostp){
					FaceViewState faceState = ((PostpViewState)((InterfacePostp)this.desktop.getDesktop().getAllFrames()[i]).getView().getViewState()).getFaceViewState();
					faceState.setTextFont((String)this.fontComboBox.getSelectedItem());
					faceState.setTextSize((int)Integer.parseInt((String)this.fontSizeComboBox.getSelectedItem()));
					if(plainRadioButton.isSelected()){
						faceState.setTextStyle((byte)(Font.PLAIN));
					}
					if(boldRadioButton.isSelected()){
						faceState.setTextStyle((byte)(Font.BOLD));
					}
					if(italicRadioButton.isSelected()){
						faceState.setTextStyle((byte)(Font.ITALIC));
					}
					if(boldRadioButton.isSelected()&&italicRadioButton.isSelected()){
						faceState.setTextStyle((byte)(Font.BOLD+Font.ITALIC));
					}
					faceState.setLabelColor(this.labelColorTextField.getBackground());
					faceState.setLabelOn(this.labelOnCheckBox.isSelected());
					faceState.setLabelOn(!this.labelOffCheckBox.isSelected());
					
					faceState.setFillType((String)this.fillTypeFaceComboBox.getSelectedItem());
					faceState.setFillColor(this.faceColorTextField.getBackground());
					float aux = Float.parseFloat(intensityFillFaceTextField.getText());
					if(aux>1.0f){
						aux=1.0f;
					}else if(aux<0){
						aux=0f;
					}
					faceState.setIntensity(aux);
					faceState.setFillStateType((String)this.fillTypeStateFaceComboBox.getSelectedItem());
					faceState.setFillStateColor(this.faceStateColorTextField.getBackground());
					aux = Float.parseFloat(intensityFillStateFaceTextField.getText());
					if(aux>1.0f){
						aux=1.0f;
					}else if(aux<0){
						aux=0f;
					}
					faceState.setIntensityState(aux);
					
					((InterfacePostp)this.desktop.getDesktop().getAllFrames()[i]).getView().getDrawingArea().repaint();
				}
			}
			
		}else if(modifySelectedCheckBox.isSelected()){
			FaceViewState faceState = ((PostpViewState)((InterfacePostp)this.desktop.getDesktop().getSelectedFrame()).getView().getViewState()).getFaceViewState();
			faceState.setTextFont((String)this.fontComboBox.getSelectedItem());
			faceState.setTextSize((int)Integer.parseInt((String)this.fontSizeComboBox.getSelectedItem()));
			if(plainRadioButton.isSelected()){
				faceState.setTextStyle((byte)(Font.PLAIN));
			}
			if(boldRadioButton.isSelected()){
				faceState.setTextStyle((byte)(Font.BOLD));
			}
			if(italicRadioButton.isSelected()){
				faceState.setTextStyle((byte)(Font.ITALIC));
			}
			if(boldRadioButton.isSelected()&&italicRadioButton.isSelected()){
				faceState.setTextStyle((byte)(Font.BOLD+Font.ITALIC));
			}
			faceState.setLabelColor(this.labelColorTextField.getBackground());
			faceState.setLabelOn(this.labelOnCheckBox.isSelected());
			faceState.setLabelOn(!this.labelOffCheckBox.isSelected());
			
			faceState.setFillType((String)this.fillTypeFaceComboBox.getSelectedItem());
			faceState.setFillColor(this.faceColorTextField.getBackground());
			float aux = Float.parseFloat(intensityFillFaceTextField.getText());
			if(aux>1.0f){
				aux=1.0f;
			}else if(aux<0){
				aux=0f;
			}
			faceState.setIntensity(aux);
			faceState.setFillStateType((String)this.fillTypeStateFaceComboBox.getSelectedItem());
			faceState.setFillStateColor(this.faceStateColorTextField.getBackground());
			aux = Float.parseFloat(intensityFillStateFaceTextField.getText());
			if(aux>1.0f){
				aux=1.0f;
			}else if(aux<0){
				aux=0f;
			}
			faceState.setIntensityState(aux);
			
			this.desktop.repaint();
			((InterfacePostp)this.desktop.getDesktop().getSelectedFrame()).getView().getDrawingArea().repaint();
		}
		
	}
	
	
	
	private void faceLabelsColorActionPerformed(ActionEvent e) {
		labelColorTextField.setBackground(JColorChooser.showDialog(this, "Choose Label Color", labelColorTextField.getBackground()));
	}
	
	private void faceColorActionPerformed(ActionEvent e) {
		faceColorTextField.setBackground(JColorChooser.showDialog(this, "Choose Label Color", faceColorTextField.getBackground()));
	}
	
	private void faceStateColorActionPerformed(ActionEvent e) {
		faceStateColorTextField.setBackground(JColorChooser.showDialog(this, "Choose Label Color", faceStateColorTextField.getBackground()));
	}
	
	
	/**
	 * @param args the command line arguments
	 */
	public static void main(String args[]) {
		java.awt.EventQueue.invokeLater(new Runnable() {
			public void run() {
				new FaceSettingsDialog(new javax.swing.JFrame(), true).setVisible(true);
			}
		});
	}
	
	public DesktopPostp getDesktop() {
		return desktop;
	}
	
	public void setDesktop(DesktopPostp desktop) {
		this.desktop = desktop;
	}
	
	public PostpViewState getState() {
		return state;
	}
	
	public void setState(PostpViewState state) {
		this.state = state;
	}
	
	
//	************************************************************************************************* 
}//end of this class
